home *** CD-ROM | disk | FTP | other *** search
/ Tux Racer / Tux Racer.iso / program files / Sunspire Studios / Tux Racer / setup.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2001-12-18  |  2.3 KB  |  109 lines

  1. #!/bin/sh
  2. #
  3. # Product setup script - Loki Entertainment Software
  4.  
  5. # Go to the proper setup directory (if not already there)
  6. cd `dirname $0`
  7.  
  8. # Return the appropriate architecture string
  9. DetectARCH()
  10. {
  11.     status=1
  12.     case `uname -m` in
  13.         i?86)  echo "x86"
  14.             status=0;;
  15.         *)     echo "`uname -m`"
  16.             status=0;;
  17.     esac
  18.     return $status
  19. }
  20.  
  21. # Return the appropriate version string
  22. DetectLIBC()
  23. {
  24.       status=1
  25.       if [ `uname -s` != Linux ]; then
  26.           echo "glibc-2.1"
  27.           return $status
  28.       fi
  29.       if [ -f `echo /lib/libc.so.6* | tail -1` ]; then
  30.           if fgrep GLIBC_2.1 /lib/libc.so.6* 2>&1 >/dev/null; then
  31.                   echo "glibc-2.1"
  32.                   status=0
  33.           else    
  34.                   echo "glibc-2.0"
  35.                   status=0
  36.           fi        
  37.       elif [ -f /lib/libc.so.5 ]; then
  38.           echo "libc5"
  39.           status=0
  40.       else
  41.           echo "unknown"
  42.       fi
  43.       return $status
  44. }
  45.  
  46. # Detect the Linux environment
  47. arch=`DetectARCH`
  48. libc=`DetectLIBC`
  49. os=`uname -s`
  50.  
  51. # Find the installation program
  52. try_run()
  53. {
  54.     setup=$1
  55.     shift
  56.     fatal=$1
  57.     if [ "$1" != "" ]; then
  58.         shift
  59.     fi
  60.  
  61.     # First find the binary we want to run
  62.     failed=0
  63.     setup_bin="setup.data/bin/$os/$arch/$libc/$setup"
  64.     if [ ! -f "$setup_bin" ]; then
  65.         setup_bin="setup.data/bin/$os/$arch/$setup"
  66.         if [ ! -f "$setup_bin" ]; then
  67.             failed=1
  68.         fi
  69.     fi
  70.     if [ "$failed" -eq 1 ]; then
  71.         if [ "$fatal" != "" ]; then
  72.             cat <<__EOF__
  73. This installation doesn't support $libc on $os / $arch
  74.  
  75. Please contact Loki Technical Support at support@lokigames.com
  76. __EOF__
  77.             exit 1
  78.         fi
  79.         return $failed
  80.     fi
  81.  
  82.     # Try to run the binary
  83.     # The executable is here but we can't execute it from CD
  84.     setup="$HOME/.setup$$"
  85.     cp "$setup_bin" "$setup"
  86.     chmod 700 "$setup"
  87.     if [ "$fatal" != "" ]; then
  88.         "$setup" $*
  89.         failed=$?
  90.     else
  91.         "$setup" $* 2>/dev/null
  92.         failed=$?
  93.     fi
  94.     rm -f "$setup"
  95.     return $failed
  96. }
  97.  
  98.  
  99. # Try to run the setup program
  100. status=0
  101. rm -f "$setup"
  102. try_run setup.gtk $* || try_run setup $* -fatal || {
  103.     echo "The setup program seems to have failed on $arch/$libc"
  104.     echo
  105.     echo "Please contact Sunspire Studios Technical Support at support@sunspirestudios.com"
  106.     status=1
  107. }
  108. exit $status
  109.